package com.construction_Safety.leave.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.construction_Safety.common.annotation.Log;
import com.construction_Safety.common.core.controller.BaseController;
import com.construction_Safety.common.core.domain.AjaxResult;
import com.construction_Safety.common.enums.BusinessType;
import com.construction_Safety.leave.domain.CLeaveUser;
import com.construction_Safety.leave.service.ICLeaveUserService;
import com.construction_Safety.common.utils.poi.ExcelUtil;
import com.construction_Safety.common.core.page.TableDataInfo;

/**
 * 请假员工管理Controller
 * 
 * @author yat
 * @date 2025-11-10
 */
@RestController
@RequestMapping("/CLeaveUser/CLeaveUser")
public class CLeaveUserController extends BaseController
{
    @Autowired
    private ICLeaveUserService cLeaveUserService;

    /**
     * 查询请假员工管理列表
     */
    @PreAuthorize("@ss.hasPermi('CLeaveUser:CLeaveUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(CLeaveUser cLeaveUser)
    {
        startPage();
        List<CLeaveUser> list = cLeaveUserService.selectCLeaveUserList(cLeaveUser);
        return getDataTable(list);
    }

    /**
     * 导出请假员工管理列表
     */
    @PreAuthorize("@ss.hasPermi('CLeaveUser:CLeaveUser:export')")
    @Log(title = "请假员工管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CLeaveUser cLeaveUser)
    {
        List<CLeaveUser> list = cLeaveUserService.selectCLeaveUserList(cLeaveUser);
        ExcelUtil<CLeaveUser> util = new ExcelUtil<CLeaveUser>(CLeaveUser.class);
        util.exportExcel(response, list, "请假员工管理数据");
    }

    /**
     * 获取请假员工管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('CLeaveUser:CLeaveUser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cLeaveUserService.selectCLeaveUserById(id));
    }

    /**
     * 新增请假员工管理
     */
    @PreAuthorize("@ss.hasPermi('CLeaveUser:CLeaveUser:add')")
    @Log(title = "请假员工管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CLeaveUser cLeaveUser)
    {
        return toAjax(cLeaveUserService.insertCLeaveUser(cLeaveUser));
    }

    /**
     * 修改请假员工管理
     */
    @PreAuthorize("@ss.hasPermi('CLeaveUser:CLeaveUser:edit')")
    @Log(title = "请假员工管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CLeaveUser cLeaveUser)
    {
        return toAjax(cLeaveUserService.updateCLeaveUser(cLeaveUser));
    }

    /**
     * 删除请假员工管理
     */
    @PreAuthorize("@ss.hasPermi('CLeaveUser:CLeaveUser:remove')")
    @Log(title = "请假员工管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cLeaveUserService.deleteCLeaveUserByIds(ids));
    }
}
